package logic

import (
	"context"
	"manage/models/mysql"

	"manage/managerpc/internal/svc"
	"manage/managerpc/managerpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type ManageShowLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewManageShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ManageShowLogic {
	return &ManageShowLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *ManageShowLogic) ManageShow(in *managerpc.ManageShowRequest) (*managerpc.ManageShowResponse, error) {
	// todo: add your logic here and delete this line

	var manage mysql.Manage
	mysql.DB.Debug().Where("id =?", in.ManageId).Find(&manage)
	return &managerpc.ManageShowResponse{
		ManageId:   int64(manage.ID),
		UserId:     manage.UserId,
		Image:      manage.Image,
		ManageName: manage.ManageName,
		Num:        int64(manage.Num),
	}, nil
}
